<template>
	<view>
		<view class="box_1">
			<view class="avatar_box">
				<u-upload :show-progress="false" :deletable="false" :show-upload-list="false" :custom-btn="true"
					:action="uploadUrl" :multiple="false"
					:header="{'Content-Type': 'multipart/form-data', 'user-token': userToken, platform: platform}"
					@on-change="uploadAvatar" @on-choose-complete="onChooseComplete" @on-error="handleUploadError"
					:max-size="(1024 * 1024)*fileupload_size" @on-oversize="handleOversize"
					:limitType="['png', 'jpg', 'jpeg', 'bmp', 'gif']" ref="uUpload">
					<image slot="addBtn" :src="basic.photo_img_src" :alt="basic.fullname"
						:class="basic.photo_img_src ? 'avatar has' : 'avatar'"></image>
				</u-upload>
			</view>
		</view>
		<view class="box_2">头像，一份好工作的开始</view>
		<!-- 抖音小程序保存 姓名  违规内容无法保存-->
		<u-field placeholder-style="color:#757575;font-size:14px !important;" v-model="basic.fullname" required
			label="姓名" placeholder="请填写" class="reset_after" :clearable="false" />
		<u-field required disabled class="none-input" name="sex" label="性别">
			<u-radio-group slot="right" v-model="basic.sex" size="28rpx">
				<u-radio name="1">男</u-radio>
				<u-radio name="2">女</u-radio>
			</u-radio-group>
		</u-field>
		<view class="box_5">
			<view class="item" @click="showPickerBirthday = !showPickerBirthday">
				<view class="tx1">出生日期</view>
				<view class="tx2">{{ basic.birthday }}</view>
			</view>
			<view class="item" @click="showPickerEnterJob = !showPickerEnterJob">
				<view class="tx1">开始工作时间</view>
				<view class="tx2">{{ basic.enter_job_time_name }}</view>
			</view>
			<view class="item" @click="showPickerEdu = !showPickerEdu">
				<view class="tx1">最高学历</view>
				<view class="tx2">{{ basic.educationName }}</view>
			</view>
		</view>
		<!-- <u-picker v-model="currentDateBirthday" type="year-month" title="选择出生日期" :start-year="minDate" :end-year="maxBirthdayDate" @confirm="onConfirmBirthday" @cancel="showPickerBirthday = false" /> -->
		<u-picker v-model="showPickerBirthday" :end-year="maxBirthdayDate" :default-time="defaultBirthdayDate"
			mode="time" title="选择出生日期" @confirm="onConfirmBirthday" @cancel="showPickerBirthday = false" />

		<!-- <u-picker  v-model="currentDateEnterJob" type="year-month" title="" :start-year="minDate" :end-year="maxDate" @confirm="onConfirmEnterJob" @cancel="showPickerEnterJob = false" /> -->
		<u-picker v-model="showPickerEnterJob" mode="time" :params="enterJobParams" @confirm="onConfirmEnterJob"
			@cancel="showPickerEnterJob = false" />

		<!-- <u-picker v-model="showPickerEdu" type="selector" :range="columnsEdu" range-key="text" :default-index="educationDefaultIndex" @confirm="onConfirmEducation" @cancel="showPickerEdu = false" /> -->
		<u-picker v-model="showPickerEdu" mode="selector" :range="columnsEdu" range-key="text"
			@confirm="onConfirmEducation" @cancel="showPickerEdu = false" />

		<u-field placeholder-style="color:#757575;font-size:14px !important;" disabled required v-model="contact.mobile"
			:clearable="false" label="联系电话" placeholder="请填写联系电话" class="reset_after" readonly>
			<view slot="right">
				<view class="edit_phone" @click="displayMobilePop">修改手机号</view>
			</view>
		</u-field>

		<!-- <u-field 
			:required="fieldStore.contact.weixin.is_require == 1" 
			v-if="fieldStore.contact.weixin.is_display == 1"
			v-model="contact.weixin" 
			:label="fieldStore.contact.weixin.field_cn" 
			placeholder="请填写联系微信"
			class="reset_after no_border" 
			:clearable="false"
			/> -->
		<!-- <view class="for_btn" v-if="fieldStore.contact.weixin.is_display">
			<view class="sync_phone">
				<u-checkbox shape="circle" v-model="wxSyncPhone" @change="syncWxPhone" icon-size="16px">同手机号</u-checkbox>
			</view>
		</view> -->
		<view class="form_split_10"></view>
		<u-field placeholder-style="color:#757575;font-size:14px !important;"
			:required="fieldStore.basic.residence.is_require == 1" v-if="fieldStore.basic.residence.is_display == 1"
			v-model="basic.residence" :label="fieldStore.basic.residence.field_cn" placeholder="请填写"
			class="reset_after" />
		<!-- 婚姻状况 -->
		<view class="form-line u-border-bottom" v-if="fieldStore.basic.marriage.is_display == 1"
			@click="showPickerMarriage = !showPickerMarriage">
			<view class="form-field">
				<view class="label" :class="fieldStore.basic.marriage.is_require == 1 ? '' : 'no'">
					{{fieldStore.basic.marriage.field_cn}}
				</view>
				<view :class="basic.marriageName ? 'text' : 'text ac'">
					{{basic.marriageName ? basic.marriageName : '请选择'}}
				</view>
			</view>
			<u-icon class="arrow-icon" name="arrow-right"></u-icon>
		</view>
		<u-picker v-model="showPickerMarriage" mode="selector" :range="columnsMarriage" range-key="text"
			:default-index="marriageDefaultIndex" @confirm="onConfirmMarriage" @cancel="showPickerMarriage = false" />
		<view class="form_split_10"></view>
		<view class="box_3" v-if="showMoreBtn" @click="showMoreInfo = !showMoreInfo">
			<view :class="showMoreInfo ? 'txt up' : 'txt'">
				完善信息，获得更多求职机会
			</view>
		</view>
		<view v-if="showMoreBtn" class="form_split_10"></view>
		<!-- 专业 -->
		<view v-if="showMoreInfo">
			<view class="form-line u-border-bottom" v-if="fieldStore.basic.major.is_display == 1"
				@click="showPickerMajor = !showPickerMajor">
				<view class="form-field">
					<view class="label" :class="fieldStore.basic.major.is_require == 1 ? '' : 'no'">
						{{fieldStore.basic.major.field_cn}}
					</view>
					<view :class="basic.majorName ? 'text' : 'text ac'">
						{{basic.majorName ? basic.majorName : '请选择'}}
					</view>
				</view>
				<u-icon class="arrow-icon" name="arrow-right"></u-icon>
			</view>
			<u-select :default-value="majorDefaultAry" v-model="showPickerMajor" mode="mutil-column-auto"
				:list="columnsMajor" @confirm="onConfirmMajor" @cancel="showPickerMajor = false">
			</u-select>

			<!-- 身高 -->
			<u-field placeholder-style="color:#757575;font-size:14px !important;"
				v-if="fieldStore.basic.height.is_display == 1" :required="fieldStore.basic.height.is_require == 1"
				v-model="basic.height" :clearable="false" :label="fieldStore.basic.height.field_cn" placeholder="请填写"
				class="reset_after" />
			<!-- 籍贯 -->
			<u-field placeholder-style="color:#757575;font-size:14px !important;"
				:required="fieldStore.basic.householdaddress.is_require == 1"
				v-if="fieldStore.basic.householdaddress.is_display == 1" v-model="basic.householdaddress"
				:clearable="false" :label="fieldStore.basic.householdaddress.field_cn" placeholder="请填写"
				class="reset_after" />
			<!-- 邮箱 -->
			<u-field placeholder-style="color:#757575;font-size:14px !important;"
				:required="fieldStore.contact.email.is_require == 1" v-model="contact.email"
				v-if="fieldStore.contact.email.is_display == 1" :clearable="false"
				:label="fieldStore.contact.email.field_cn" placeholder="请填写" class="reset_after" />
			<!-- qq -->
			<u-field placeholder-style="color:#757575;font-size:14px !important;"
				:required="fieldStore.contact.qq.is_require == 1" v-model="contact.qq"
				v-if="fieldStore.contact.qq.is_display == 1" :clearable="false" :label="fieldStore.contact.qq.field_cn"
				placeholder="请填写" class="reset_after" />
			<!-- 自定义1 -->
			<u-field placeholder-style="color:#757575;font-size:14px !important;"
				:required="fieldStore.basic.custom_field_1.is_require == 1"
				v-if="fieldStore.basic.custom_field_1.is_display == 1" v-model="basic.custom_field_1" :clearable="false"
				:label="fieldStore.basic.custom_field_1.field_cn" placeholder="请填写" class="reset_after" />
			<!-- 自定义2 -->
			<u-field placeholder-style="color:#757575;font-size:14px !important;"
				:required="fieldStore.basic.custom_field_2.is_require == 1"
				v-if="fieldStore.basic.custom_field_2.is_display == 1" v-model="basic.custom_field_2" :clearable="false"
				:label="fieldStore.basic.custom_field_2.field_cn" placeholder="请填写" class="reset_after" />
			<!-- 自定义3 -->
			<u-field placeholder-style="color:#757575;font-size:14px !important;"
				:required="fieldStore.basic.custom_field_3.is_require == 1" v-model="basic.custom_field_3"
				v-if="fieldStore.basic.custom_field_3.is_display == 1" :clearable="false"
				:label="fieldStore.basic.custom_field_3.field_cn" placeholder="请填写" class="reset_after no_border" />
			<!-- <view class="box_4" v-if="fieldStore.basic.idcard.is_display">身份证号仅用于系统身份认证，未经允许不会对外公开</view> -->
			<!-- 身份证 -->
			<!-- <u-field placeholder-style="color:#757575;font-size:14px !important;"
				:required="fieldStore.basic.idcard.is_require == 1" v-if="fieldStore.basic.idcard.is_display == 1"
				v-model="basic.idcard" :clearable="false" :label="fieldStore.basic.idcard.field_cn" placeholder="请填写"
				class="reset_after no_border" /> -->
		</view>
		<view style="margin: 32rpx;">
			<u-button shape="circle" type="primary" :disabled="disabled" @click="handleSubmit">
				保存
			</u-button>
		</view>
		<u-modal v-model="showMobilePop" title="更换手机号" show-cancel-button :before-close="beforeClose"
			@confirm="$refs.update_phone_number.handleSubmit()">
			<UpdatePhoneNumber ref="update_phone_number" :show_mobile="contact.mobile" @closePopup="closeMobilePop">
			</UpdatePhoneNumber>
		</u-modal>
		<u-mask :show="uploading">
			<view class="uploading_box">
				<u-loading type="spinner" size="58rpx"></u-loading>正在上传...
			</view>
		</u-mask>
		<u-top-tips ref="uTips"></u-top-tips>
	</view>
</template>

<script>
	import UpdatePhoneNumber from './components/UpdatePhoneNumber'
	import http from '@/utils/http'
	import api from '@/api'
	import {
		mapState
	} from 'vuex'
	export default {
		name: 'EditBasic',
		components: {
			UpdatePhoneNumber
		},
		data() {
			return {
				defaultBirthdayDate: '',
				uploading: false,
				uploadUrl: getApp().globalData.baseURL + api.uploadFile,
				enable_close_mobile: true,
				majorStart: '',
				majorDefaultIndex1: 0,
				majorDefaultIndex2: 0,
				majorDefaultAry: [0, 0],
				marriageDefaultIndex: 0,
				educationDefaultIndex: 0,
				showPickerEdu: false,
				showPickerEnterJob: false,
				showPickerBirthday: false,
				showPickerMarriage: false,
				showMoreInfo: false,
				showPickerMajor: false,
				showMobilePop: false,
				wxSyncPhone: false,
				isNoJobTime: false,
				currentDateEnterJob: '',
				currentDateBirthday: '',
				minDate: '',
				maxDate: '',
				maxBirthdayDate: '',
				basic: {
					fullname: '',
					sex: '1',
					birthday: '',
					education: 1,
					educationName: '',
					enter_job_time: '',
					enter_job_time_name: '',
					photo_img: 0,
					photo_img_src: '',
					residence: '',
					marriage: 0,
					marriageName: '',
					major1: 0,
					major2: 0,
					majorName: '',
					// idcard: '',
					height: 0,
					householdaddress: '',
					custom_field_1: '',
					custom_field_2: '',
					custom_field_3: ''
				},
				contact: {
					mobile: '',
					weixin: '',
					email: '',
					qq: ''
				},
				enterJobParams: {
					year: true,
					month: true,
					day: false,
					hour: false,
					minute: false,
					second: false,
					timestamp: false,
				},
				disabled: false
			}
		},
		created() {
			this.initDate()
			this.initData()
			this.$store.dispatch('getClassify', 'education').then(() => {
				// 恢复最高学历
				this.educationDefaultIndex = this.columnsEdu.findIndex(
					item => parseInt(item.id) === parseInt(this.basic.education)
				)
			})
			this.$store.dispatch('getClassify', 'marriage').then(() => {
				// 恢复婚姻状况
				this.marriageDefaultIndex = this.columnsMarriage.findIndex(
					item => parseInt(item.id) === parseInt(this.basic.marriage)
				)
			})
			this.$store.dispatch('getClassify', 'major').then(() => {
				// 恢复所学专业
				let pickerMajor = this.$store.state.classifyMajorOriginal
				if (this.basic.major1) {
					let _this = this
					Object.keys(pickerMajor).forEach(function(key, index) {
						if (parseInt(pickerMajor[key].value) === parseInt(_this.basic.major1)) {
							_this.majorDefaultIndex1 = index
							_this.majorStart = pickerMajor[key].label
							_this.basic.majorName = _this.majorStart + '-' + _this.basic.majorName
							_this.majorDefaultIndex2 = pickerMajor[key].children.findIndex(
								item => parseInt(item.value) === parseInt(_this.basic.major2)
							)
							_this.majorDefaultAry = [_this.majorDefaultIndex1, _this.majorDefaultIndex2]
						}
					})
				} else {
					this.majorDefaultIndex1 = 0
					this.majorStart = pickerMajor[0].label
					this.majorDefaultIndex2 = 0
					this.majorDefaultAry = [0, 0]
				}
			})

			// 恢复出生日期和开始工作时间
			let birthdayDateArr = this.basic.birthday.split('-')
			this.currentDateBirthday = new Date(
				parseInt(birthdayDateArr[0]),
				parseInt(birthdayDateArr[1]) - 1
			)
			if (this.basic.enter_job_time) {
				// 有工作经验
				let enterJobDateArr = this.basic.enter_job_time.split('-')
				this.currentDateEnterJob = new Date(
					parseInt(enterJobDateArr[0]),
					parseInt(enterJobDateArr[1]) - 1
				)
			}
		},
		watch: {
			'contact.weixin': function() {
				this.$nextTick(function() {
					this.wxSyncPhone = this.contact.mobile === this.contact.weixin
				})
			},
			'basic.fullname': function(newVal) { //简历姓名过滤掉输入的表情包
				var sanitizedText = newVal.replace(/[^\u4e00-\u9fa5a-zA-Z0-9]/g, ''); // 将UTF-16编码的表情包过滤掉
				if (sanitizedText !== newVal) {
					this.basic.fullname = sanitizedText; // 将过滤后的文本重新赋值给组件的输入内容
				}
			}
		},
		computed: {
			...mapState({
				userToken: state => state.userToken,
				platform: state => state.platform,
				fileupload_size: state => state.config.fileupload_size / 1024
			}),
			columnsEdu() {
				return this.$store.state.classifyEdu
			},
			columnsMarriage() {
				return this.$store.state.classifyMarriage
			},
			columnsMajor() {
				return this.$store.state.classifyMajorOriginal
			},
			basicStore() {
				return this.$store.state.resume.basic
			},
			contactStore() {
				return this.$store.state.resume.contact
			},
			fieldStore() {
				return this.$store.state.resume.field_rule
			},
			showMoreBtn() {
				return this.$store.state.resume.field_rule.basic.major.is_display == 1 ||
					this.$store.state.resume.field_rule.basic.height.is_display == 1 ||
					this.$store.state.resume.field_rule.basic.householdaddress.is_display == 1 ||
					this.$store.state.resume.field_rule.contact.email.is_display == 1 ||
					this.$store.state.resume.field_rule.contact.qq.is_display == 1 ||
					this.$store.state.resume.field_rule.basic.custom_field_1.is_display == 1 ||
					this.$store.state.resume.field_rule.basic.custom_field_2.is_display == 1 ||
					this.$store.state.resume.field_rule.basic.custom_field_3.is_display == 1 ||
					this.$store.state.resume.field_rule.basic.idcard.is_display == 1
			}
		},
		onReady() {
			this.defaultBirthdayDate = (new Date().getFullYear() - 16) + '-' + (new Date().getMonth() + 1)
		},
		methods: {
			/**
			 * logo 上传失败回调函数
			 * */
			handleUploadError(error) {
				this.uploading = false
			},
			beforeClose(action, done) {
				if (action === 'cancel') {
					this.enable_close_mobile = true
				}
				if (this.enable_close_mobile === true) {
					done()
				} else {
					done(false)
				}
			},
			displayMobilePop() {
				this.showMobilePop = true
				this.enable_close_mobile = false
			},
			closeMobilePop(mobile) {
				this.contact.mobile = mobile
				if (this.wxSyncPhone === true) {
					this.contact.weixin = mobile
				}
				this.showMobilePop = false
			},
			// 同手机号
			syncWxPhone(checked) {
				if (checked) {
					this.contact.weixin = this.contact.mobile
				}
			},
			// 头部返回
			goBack() {
				window.history.length > 1 ? uni.navigateBack({
					delta: 1
				}) : uni.navigateTo({
					url: '/'
				})
			},
			// 初始化接口返回数据
			initData() {
				// 初始化接口返回数据
				let interfaceBasic = this.basicStore
				let interfaceContact = this.contactStore
				this.basic.photo_img_src = interfaceBasic.photo_img_src
				this.basic.photo_img = interfaceBasic.photo_img
				this.basic.fullname = interfaceBasic.fullname
				this.basic.sex = '' + interfaceBasic.sex + ''
				this.basic.birthday = interfaceBasic.birthday
				if (interfaceBasic.enter_job_time) {
					let enterDate = this.dateFormat(
						new Date(interfaceBasic.enter_job_time * 1000)
					)
					this.basic.enter_job_time = enterDate
					this.basic.enter_job_time_name = enterDate
				} else {
					// 无工作经验
					this.basic.enter_job_time = ''
					this.basic.enter_job_time_name = '无工作经验'
					this.isNoJobTime = true
				}
				this.basic.education = interfaceBasic.education
				this.basic.educationName = interfaceBasic.education_text
				this.contact.mobile = interfaceContact.mobile
				this.contact.weixin = interfaceContact.weixin
				this.wxSyncPhone = this.contact.mobile === this.contact.weixin
				this.basic.householdaddress = interfaceBasic.householdaddress
				this.basic.marriage = interfaceBasic.marriage
				this.basic.marriageName = interfaceBasic.marriage_text
				this.basic.major1 = interfaceBasic.major1
				this.basic.major2 = interfaceBasic.major2
				this.basic.majorName = interfaceBasic.major_text
				this.basic.height = interfaceBasic.height
				this.basic.residence = interfaceBasic.residence
				this.contact.email = interfaceContact.email
				this.contact.qq = interfaceContact.qq
				// this.basic.idcard = interfaceBasic.idcard
				this.basic.custom_field_1 = interfaceBasic.custom_field_1
				this.basic.custom_field_2 = interfaceBasic.custom_field_2
				this.basic.custom_field_3 = interfaceBasic.custom_field_3
			},
			// 设置日期插件默认值
			initDate() {
				let nowDate = new Date()
				let nowYear = nowDate.getFullYear()
				this.minDate = nowYear - 59
				this.maxDate = nowYear
				this.maxBirthdayDate = nowYear - 16
			},
			// 选择出生日期
			onConfirmBirthday(value) {
				this.basic.birthday = value.year + '-' + value.month + '-' + value.day
				this.showPickerBirthday = !this.showPickerBirthday
			},
			// 选择开始工作时间
			onConfirmEnterJob(value) {
				this.basic.enter_job_time = value.year + '-' + value.month
				this.basic.enter_job_time_name = value.year + '-' + value.month
				this.isNoJobTime = false
				this.showPickerEnterJob = !this.showPickerEnterJob
			},
			// 选择无工作经验
			handleNoJobTime() {
				this.basic.enter_job_time = ''
				this.basic.enter_job_time_name = '无工作经验'
				this.isNoJobTime = true
				this.showPickerEnterJob = !this.showPickerEnterJob
			},
			// 选择最高学历
			onConfirmEducation(index) {
				this.basic.education = this.columnsEdu[index].id
				this.basic.educationName = this.columnsEdu[index].text
				this.showPickerEdu = !this.showPickerEdu
			},
			// 选择婚姻状况
			onConfirmMarriage(index) {
				this.basic.marriage = this.columnsMarriage[index].id
				this.basic.marriageName = this.columnsMarriage[index].text
				this.showPickerMarriage = !this.showPickerMarriage
			},
			// 选择所学专业
			onConfirmMajor(currentMajorObj) {
				var [columnObj1, columnObj2] = currentMajorObj
				let majorCategory = this.$store.state.classifyMajorOriginal
				this.basic.major1 = columnObj1.value
				this.basic.major2 = columnObj2.value
				let major1Text = columnObj1.label
				let major2Text = columnObj2.label
				this.basic.majorName = `${major1Text}-${major2Text}`
				for (var i = 0; i < majorCategory.length; i++) {
					let item = majorCategory[i]
					if (columnObj1.label == item.label) {
						for (var i2 = 0; i2 < item.children.length; i2++) {
							let item2 = item.children[i2]
							if (columnObj2.label == item2.label) {
								this.majorDefaultAry = [i, i2]
							}
						}
					}
				}
				this.showPickerMajor = !this.showPickerMajor
			},
			// 保存
			handleSubmit() {
				if (this.fieldStore.basic.photo_img.is_display == 1 && this.fieldStore.basic.photo_img.is_require == 1) {
					if (!this.basic.photo_img) {
						this.$refs.uTips.show({
							title: '请上传头像',
							type: 'error'
						})
						return false
					}
				}
				if (!this.basic.fullname) {
					this.$refs.uTips.show({
						title: '请填写姓名',
						type: 'error'
					})
					return false
				}
				if (!this.basic.sex) {
					this.$refs.uTips.show({
						title: '请选择性别',
						type: 'error'
					})
					return false
				}
				if (!this.basic.birthday) {
					this.$refs.uTips.show({
						title: '请选择出生日期',
						type: 'error'
					})
					return false
				}
				if (!this.isNoJobTime) {
					if (!this.basic.enter_job_time) {
						this.$refs.uTips.show({
							title: '请选择开始工作时间',
							type: 'error'
						})
						return false
					}
				}
				if (!this.basic.education) {
					this.$refs.uTips.show({
						title: '请选择学历',
						type: 'error'
					})
					return false
				}
				if (!this.contact.mobile) {
					this.$refs.uTips.show({
						title: '请填写联系电话',
						type: 'error'
					})
					return false
				}
				this.contact.weixin = this.contact.mobile
				// if (this.fieldStore.contact.weixin.is_display == 1 && this.fieldStore.contact.weixin.is_require == 1) {
				// 	if (!this.contact.weixin) {
				// 		this.$refs.uTips.show({
				// 			title: '请填写' + this.fieldStore.contact.weixin.field_cn,
				// 			type: 'error'
				// 		})
				// 		return false
				// 	}
				// }
				if (this.fieldStore.basic.residence.is_display == 1 && this.fieldStore.basic.residence.is_require == 1) {
					if (!this.basic.residence) {
						this.$refs.uTips.show({
							title: '请填写' + this.fieldStore.basic.residence.field_cn,
							type: 'error'
						})
						return false
					}
				}
				if (this.fieldStore.basic.marriage.is_display == 1 && this.fieldStore.basic.marriage.is_require == 1) {
					if (this.basic.marriage === '') {
						this.$refs.uTips.show({
							title: '请选择' + this.fieldStore.basic.marriage.field_cn,
							type: 'error'
						})
						return false
					}
				}
				if (this.fieldStore.basic.major.is_display == 1 && this.fieldStore.basic.major.is_require == 1) {
					if (!this.basic.major1) {
						this.$refs.uTips.show({
							title: '请在下方完善信息中选择' + this.fieldStore.basic.major.field_cn,
							type: 'error'
						})
						return false
					}
				}
				if (this.fieldStore.basic.height.is_display == 1 && this.fieldStore.basic.height.is_require == 1) {
					if (!this.basic.height) {
						this.$refs.uTips.show({
							title: '请在下方完善信息中填写' + this.fieldStore.basic.height.field_cn,
							type: 'error'
						})
						return false
					}
				}
				if (this.fieldStore.basic.householdaddress.is_display == 1 && this.fieldStore.basic.householdaddress
					.is_require == 1) {
					if (!this.basic.householdaddress) {
						this.$refs.uTips.show({
							title: '请在下方完善信息中填写' + this.fieldStore.basic.householdaddress.field_cn,
							type: 'error'
						})
						return false
					}
				}
				if (this.fieldStore.contact.email.is_display == 1 && this.fieldStore.contact.email.is_require == 1) {
					if (!this.contact.email) {
						this.$refs.uTips.show({
							title: '请在下方完善信息中填写' + this.fieldStore.contact.email.field_cn,
							type: 'error'
						})
						return false
					}
				}
				if (this.fieldStore.contact.qq.is_display == 1 && this.fieldStore.contact.qq.is_require == 1) {
					if (!this.contact.qq) {
						this.$refs.uTips.show({
							title: '请在下方完善信息中填写' + this.fieldStore.contact.qq.field_cn,
							type: 'error'
						})
						return false
					}
				}
				if (this.fieldStore.basic.custom_field_1.is_display == 1 && this.fieldStore.basic.custom_field_1
					.is_require == 1) {
					if (!this.basic.custom_field_1) {
						this.$refs.uTips.show({
							title: '请在下方完善信息中填写' + this.fieldStore.basic.custom_field_1.field_cn,
							type: 'error'
						})
						return false
					}
				}
				if (this.fieldStore.basic.custom_field_2.is_display == 1 && this.fieldStore.basic.custom_field_2
					.is_require == 1) {
					if (!this.basic.custom_field_2) {
						this.$refs.uTips.show({
							title: '请在下方完善信息中填写' + this.fieldStore.basic.custom_field_2.field_cn,
							type: 'error'
						})
						return false
					}
				}
				if (this.fieldStore.basic.custom_field_3.is_display == 1 && this.fieldStore.basic.custom_field_3
					.is_require == 1) {
					if (!this.basic.custom_field_3) {
						this.$refs.uTips.show({
							title: '请在下方完善信息中填写' + this.fieldStore.basic.custom_field_3.field_cn,
							type: 'error'
						})
						return false
					}
				}
				// if (this.fieldStore.basic.idcard.is_display == 1 && this.fieldStore.basic.idcard.is_require == 1) {
				// 	if (!this.basic.idcard) {
				// 		this.$refs.uTips.show({
				// 			title: '请在下方完善信息中填写' + this.fieldStore.basic.idcard.field_cn,
				// 			type: 'error'
				// 		})
				// 		return false
				// 	}
				// }
				this.disabled = true
				http
					.post(api.resume_basic_save, {
						basic: {
							fullname: this.basic.fullname,
							sex: this.basic.sex,
							birthday: this.basic.birthday,
							education: this.basic.education,
							enter_job_time: this.basic.enter_job_time,
							photo_img: this.basic.photo_img,
							residence: this.basic.residence,
							marriage: this.basic.marriage,
							major1: this.basic.major1,
							major2: this.basic.major2,
							// idcard: this.basic.idcard,
							height: this.basic.height,
							householdaddress: this.basic.householdaddress,
							custom_field_1: this.basic.custom_field_1,
							custom_field_2: this.basic.custom_field_2,
							custom_field_3: this.basic.custom_field_3
						},
						contact: {
							mobile: this.contact.mobile,
							weixin: this.contact.weixin,
							email: this.contact.email,
							qq: this.contact.qq
						}
					})
					.then(res => {
						this.disabled = false
						if (parseInt(res.data.code) === 200) {
							this.$refs.uTips.show({
								title: res.data.message,
								type: 'success'
							})
							setTimeout(() => {
								uni.navigateBack({
									delta: 1
								})
							}, 1500)
						} else {
							this.$refs.uTips.show({
								title: res.data.message,
								type: 'error'
							})
						}
					})
					.catch(err => {
						console.log(err)
					})
			},
			// 上传头像
			uploadAvatar(data, index, lists, name) {
				let res = JSON.parse(data.data)
				if (parseInt(res.code) === 200) {
					this.uploading = false
					this.basic.photo_img_src = res.data.file_url
					this.basic.photo_img = res.data.file_id
					this.$refs.uUpload.clear()
				} else {
					this.uploading = false
				}
			},
			handleOversize() {
				uni.showToast({
					title: "图片最大不能超过" + this.fileupload_size + "M",
					icon: 'none'
				})
			},
			onChooseComplete(lists, name) {
				if (lists.length > 0) {
					this.uploading = true
				}
			},
			// 格式化日期
			dateFormat(time) {
				let year = time.getFullYear()
				let month = time.getMonth() + 1
				return `${year}-${month}`
			}
		},
		mounted() {
			// 改变上传头像样式
			// document
			//   .querySelector('.u-uploader__wrapper')
			//   .setAttribute('style', 'height: 100%;width:100%')
			// document
			//   .querySelector('.u-uploader__upload')
			//   .setAttribute('style', 'margin: 0;height: 100%;width:100%')
			// document
			//   .querySelector('.u-uploader__input')
			//   .setAttribute('style', 'z-index: 2')
		}
	}
</script>

<style lang="scss" scoped>
	.for_btn {
		right: -14rpx;
		top: 50%;
		transform: translateY(-50%);
		z-index: 20;
	}

	.none-input {
		/deep/ .fild-body {
			/deep/ .u-flex {
				flex: 0;
				flex-shrink: 0;
				width: 0;
				margin: 0 !important;
			}
		}
	}

	.uploading_box {
		width: 100%;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;
	}

	.box_5 {
		.item {
			&:not(:last-child)::after {
				position: absolute;
				right: 0;
				top: 40rpx;
				height: 80rpx;
				border-right: 2rpx solid #e2e2e2;
				content: ' ';
			}

			.tx2 {
				padding: 15rpx 0 35rpx;
				font-size: 28rpx;
				color: #333333;
			}

			.tx1 {
				padding-top: 35rpx;
				font-size: 24rpx;
				color: #666666;
			}

			flex: 1;
			text-align: center;
			position: relative;
		}

		&::after {
			position: absolute;
			left: 0;
			box-sizing: border-box;
			content: ' ';
			pointer-events: none;
			right: 0;
			bottom: 0;
			transform: scaleY(0.5);
			border-bottom: 2rpx solid #ebebeb;
		}

		width: 100%;
		display: flex;
		background-color: #ffffff;
		position: relative;
	}

	.box_4 {
		font-size: 24rpx;
		color: #999999;
		padding: 25rpx 32rpx;
		background-color: #f3f3f3;
	}

	.box_3 {
		width: 100%;
		text-align: center;
		padding: 20rpx 0;
		background-color: #ffffff;

		.txt {
			font-size: 26rpx;
			line-height: 44rpx;
			color: #999999;
			width: 384rpx;
			margin: 0 auto;
			padding-right: 46rpx;
			position: relative;

			&::before {
				content: '';
				width: 22rpx;
				height: 22rpx;
				border: 2rpx solid #999999;
				border-radius: 100%;
				position: absolute;
				right: 0;
				top: 10rpx;
			}

			&::after {
				position: absolute;
				right: 8rpx;
				top: 16rpx;
				width: 8rpx;
				height: 8rpx;
				border-bottom: 2rpx solid #999999;
				border-right: 2rpx solid #999999;
				transform: rotate(45deg);
				content: '';
			}

			&.up {
				&::after {
					position: absolute;
					right: 8rpx;
					top: 20rpx;
					width: 8rpx;
					height: 8rpx;
					border-top: 2rpx solid #999999;
					border-left: 2rpx solid #999999;
					transform: rotate(45deg);
					content: '';
					border-right: 0;
					border-bottom: 0;
				}
			}
		}
	}

	.box_2 {
		width: 100%;
		background-color: #ffffff;
		padding: 78rpx 0 26rpx;
		text-align: center;
		font-size: 24rpx;
		color: #666666;
	}

	.box_1 {
		.avatar_box {
			position: absolute;
			left: 50%;
			top: 146rpx;
			transform: translate(-50%, 0);
			width: 150rpx;
			height: 150rpx;
			border-radius: 100%;
			border: 2rpx solid #ffffff;
			background-color: #f7f7f7;
			overflow: hidden;

			.avatar {
				position: absolute;
				left: 0;
				top: 0;
				width: 100%;
				height: 100%;
				border: 0;
				border-radius: 100%;

				&.has {
					z-index: 1;
				}
			}
		}

		position: relative;
		width: 100%;
		height: 240rpx;
		background-color: #2e95fa;

		.box_head {
			width: 100%;
			height: 104rpx;
			line-height: 104rpx;
			text-align: center;
			font-size: 34rpx;
			color: #ffffff;
			font-weight: bolder;
			position: relative;
			background-color: #2e95fa;

			.head_back {
				position: absolute;
				left: 0;
				top: 0;
				width: 80rpx;
				height: 100%;
				background: url($ImgUrl + 'back_ico_white.svg') center no-repeat;
				background-size: 40rpx;
			}
		}
	}

	.edit_phone {
		position: absolute;
		right: 0rpx;
		top: -10rpx;
		font-size: 28rpx;
		color: #2199ff;
		padding: 0 30rpx;
		height: 100rpx;
		line-height: 100rpx;
		z-index: 10;
	}

	.sync_phone {
		.u-checkbox {
			line-height: 100rpx;
			height: 100rpx;
		}

		position: absolute;
		right: 0;
		top: -100rpx;
		font-size: 28rpx;
		color: #515151;
		padding: 0 30rpx;
		height: 100rpx;
		line-height: 100rpx;
	}

	.u-overlay {
		text-align: center;
		z-index: 2;
	}

	.u-loading {
		top: 36%;
	}

	.u-loading__text {
		color: #c3c3c3;
	}
</style>